package com.tt.manage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tt.manage.mapper.ItemMapper;
import com.tt.manage.pojo.Item;
import com.tt.manage.service.ItemService;
import com.tt.util.MysqlPageUtils;
@Service
public class ItemServiceImpl implements ItemService {
	@Autowired
	private ItemMapper itemMapper;
	/***
	 * 通过id查找商品
	 * @param id 商品id
	 * @return 商品
	 */
	@Override
	public Item getItemById(Long id) throws Exception {
		// TODO Auto-generated method stub
		return itemMapper.selectByPrimaryKey(id);
	}
	/***
	 * 通过分页的方式获取列表
	 */
	@Override
	public List<Item> getItemsByPage(int page, int rows) throws Exception {
		return itemMapper.selectByPage(new MysqlPageUtils(page, rows));
	}
	/***
	 * 获取数据数量
	 */
	@Override
	public Long getItemsCount() throws Exception {
		// TODO Auto-generated method stub
		return itemMapper.selectCount();
	}

}
